<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2016/9/14
 * Time: 14:41
 * 结账步骤二
 */
require('env.php');
require('init.inc.php');
include_once 'functions.php';
$db_oid = $_GET['oid'];
if (isset($_GET['OrderProdDBId'])) {
    $OrderProdDBId = $_GET['OrderProdDBId'];
} else {
    $OrderProdDBId = '';
}


$tongji1 = home_tongji(1);
$tongji2 = home_tongji(2);
$tongji3 = home_tongji(3);
$index_std = ShopConfig::getConfig();
?>

<!DOCTYPE html>
<html>
<?php include("header.php"); ?>
<style>
    .form-group1 {
        background-color: white;
        width: 100%;
    }

    .modal-title_n {
        width: 100%;
        font-size: 20px;
    }

    .modal-ele {
        margin-left: 10%;
        font-size: 15px;
        font-weight: bold;
        line-height: 30px;
    }

    .modal-ele-blan {
        left: 70%;
        font-size: 15px;
        font-weight: bold;
        line-height: 40px;
        position: absolute;
    }

    .modal-ele1 {
        margin-left: 10%;
        font-size: 15px;
        font-weight: bold;
        line-height: 40px;
    }

    .modal-elet {
        margin-left: 80%;
        font-size: 15px;
        color: blue;
    }

    .modal-xiao {
        font-size: 18px;
        background-color: whitesmoke;
    }

    .btn-item {
        height: 50px;
        background: #FF6F20 url(style/images/btn-totop.png) 18px 18px no-repeat;
        background-size: 15px;
        bottom: 10%;
        position: fixed;
        width: 100%;
    }

    .btn-item a {
        height: 50px;
        line-height: 50px;
        display: block;
        border-left: 1px solid #FFF;
        text-align: center;
        font-size: 16px;
        color: #FFF;
        margin: 0 0 0 50px;
        font-weight: bold;
    }

    .btn_a {
        font-size: 18px;
        margin-left: 8%;
    }

    .modal-f {
        padding: 15px;
        border-top: 1px solid #e5e5e5;
    }

    .nex {
        background-color: blueviolet;
        color: white;
        width: 40%;
    }

    .grens {
        color: green;
    }

    .modal-tips {
        font-size: 10px;
    }

    .divs {
        width: 100%;
        height: 100%;
    }

    .divx {
        width: 100%
        height: 200px;

    }

    .prov {
        width: 44%;
        height: 45px;
    }

    .city {
        width: 44%;
        height: 45px;
    }

    #city_1 {
        margin-bottom: 10%;
    }
</style>

<script type="text/javascript" src="style/js/jquery.min.js"></script>
<script type="text/javascript" src="style/js/jquery.cityselect.js"></script>
<script type="text/javascript">
    $(function () {
        $("#city_1").citySelect({
            url: "city.php",
            required: false
        });
    });
</script>

<body>
<div class="form-group1" id="order_span">
    <div class="modal-header">
        <h4 class="modal-title_n">只要三步 -- <span style="color: blue;">2</span> / 3</h4>
    </div>

    <div class="divs">
        <div class="modal-ele">
            <p><span class="grens">[必填]</span>收件人</p>

            <p><input type="text" size="35" name="sjr" id="sjrt"/></p>

            <p><span class="modal-tips">請填寫收件人真實姓名</p>
        </div>

        <div class="modal-ele">
            <p>方便收貨時間</p>
            <span><input type="radio" checked value="1" id="dt1" name="shdt"/><span>不指定</span></span>
            <span><input type="radio" value="2" id="dt2" name="shdt"/><span>中午前</span></span>
            <span><input type="radio" value="3" id="dt3" name="shdt"/><span>12-17點</span></span>
            <span><input type="radio" value="4" id="dt4" name="shdt"/><span>17-19點</span></span>
        </div>
        <div class="modal-ele">
            <p><span class="grens">[必填]</span>聯絡電話</p>

            <p><input type="text" size="35" name="phone" id="phonet"/></p>

            <p><span class="modal-tips">請填入送貨司機能聯絡到您的電話 (若無行動電話可填家用電話)</p>
        </div>
<!--        <div class="modal-ele">-->
<!--            <p><span class="grens">[必填]</span>郵編</p>-->
<!---->
<!--            <p><input type="text" size="35" name="postcode" id="postcode"/></p>-->
<!---->
<!--            <p><span class="modal-tips">請輸入你地址所在地郵編</p>-->
<!--        </div>-->

        <div class="modal-ele">
            <p><span class="grens">[必填]</span>地址</p>

            <div id="city_1">
                <select class="prov" id="prov_id"></select>
                <select class="city" id="city_id" disabled="disabled"></select>

                <p><input type="text" size="35" name="addr" id="addrt" placeholder="請填寫詳細地址，具體到街道門牌號"/></p>
            </div>

        </div>
        <div class="modal-f">
        <span class="btn_a"> <input type="button" class="nex" value="上一步" onclick="pre_stp1()"/>&nbsp;&nbsp;&nbsp;&nbsp;<input
                class="nex" type="button" value="下一步" onclick="next_stp3()"/></span>
        </div>
    </div>
</div>
<div style="display:none;">
    <?php echo str_replace("&nbsp;", ' ', htmlspecialchars_decode($tongji1['tongji'], ENT_QUOTES)) . '<br/>' . str_replace("&nbsp;", ' ', htmlspecialchars_decode($tongji2['tongji'], ENT_QUOTES)) . '<br/>' . str_replace("&nbsp;", ' ', htmlspecialchars_decode($tongji3['tongji'], ENT_QUOTES)) . '<br/>'; ?>
</div>

<script type="text/javascript">
    function pre_stp1() {
        window.location.href = '<?php echo SERVER_ROOT?>' + 'invoicing_stp1.php?OrderProdDBId=' + '<?php echo $OrderProdDBId?>';
    }


    function next_stp3() {
        //提交通過了就直接可以跳轉到下一步
        var sjr = $("#sjrt").val();
        var phone = $("#phonet").val();
        var addr = $("#addrt").val();
        var postcode = $("#postcode").val();
        var shdt = '';
        $("input[name=shdt]").each(function () {
            if ($(this).attr("checked")) {
                shdt = $(this).val();
            }
        });

        var city = $("#prov_id option:selected").val();
        var qx = $("#city_id option:selected").val();

        //数据库id
        $.ajax({
            url: 'order.php',// 跳转到 action
            data: {
                isUpdate: '0_up',
                oid: '<?php echo $db_oid?>',
                sjr: sjr,
                phone: phone,
                addr: addr,
                shdt: shdt,
                city: city,
                postcode:postcode,
                qx: qx
            },
            type: 'post',
            cache: false,
            dataType: 'json',
            success: function (data) {
                if (data.msg == "true") {
                    window.location.href = '<?php echo SERVER_ROOT?>' + 'invoicing_stp3.php?oid=' + <?php echo $db_oid?> +'&OrderProdDBId=' + '<?php echo $OrderProdDBId?>';
                } else {
                    alert(data.content);
                }
            },
            error: function () {
                alert("服務器錯誤！");
            }
        });


    }


    $(document).ready(function () {
        $("input[name=shdt]").each(function () {
            $(this).click(function () {
                var discount = $(this).attr("checked");
                if (discount == undefined) {
                    $(this).attr("checked", "checked");
                }
            });
        });
    });


</script>
</body>
</html>




